﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 碧蓝肝帝
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();            
        }

        /// <summary>
        /// 程序地址
        /// </summary>
        public string dir = AppDomain.CurrentDomain.BaseDirectory;

        /// <summary>
        /// 0 代表保存日志，1代表保存活动地图坐标设置，2代表保存满员时的强化步骤设置
        /// </summary>
        public int save_class = 0;

        public string log = AppDomain.CurrentDomain.BaseDirectory + @"\Data\过程记录.txt";

        public string sp_setting = "";

        public string intensify = AppDomain.CurrentDomain.BaseDirectory + @"\Data\Intensify.txt";
        private void Form2_Load(object sender, EventArgs e)
        {
            
        }
        /// <summary>
        /// 加载日志文件
        /// </summary>
        public void Append_log()
        {                       
            var log = Text_save.Log_list;
            if (log != null)
            {
                foreach (string item in log)
                {
                    richTextBox1.AppendText(item);
                }
            }
            else
            {
                MessageBox.Show("还未有记录");
            }

        }

        /// <summary>
        /// 加载活动地图坐标文件
        /// </summary>
        public void Append_setting(string path)
        {
            sp_setting = path;
            try
            {               
                richTextBox1.LoadFile(path, RichTextBoxStreamType.PlainText);
            }
            catch
            {
                MessageBox.Show("坐标记录文件" + path +"出错");
            }
            
        }

        /// <summary>
        /// 加载满员时强化步骤文件
        /// </summary>
        public void Append_intensify()
        {
            try
            {
                richTextBox1.LoadFile(intensify, RichTextBoxStreamType.PlainText);
            }
            catch
            {
                MessageBox.Show("强化步骤记录文件出错");
            }
        }

        /// <summary>
        /// 保存坐标设置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                switch(save_class)
                {
                    case 0:
                        richTextBox1.SaveFile(log, RichTextBoxStreamType.PlainText);
                        Close();
                        break;
                    case 1:
                        richTextBox1.SaveFile(sp_setting, RichTextBoxStreamType.PlainText);
                        Close();
                        break;
                    case 2:
                        richTextBox1.SaveFile(intensify, RichTextBoxStreamType.PlainText);
                        Close();
                        break;
                    default:
                        break;
                }                                                  
            }
            catch
            {
                MessageBox.Show("文件保存时出错");
            }
            
        }

        /// <summary>
        /// 取消
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
